home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt40s3.arc / PIBGENRT.MOD < prev    next >
Text File  |  1987-09-22  |  7KB  |  156 lines

  1. (*----------------------------------------------------------------------*)
  2. (*           GENTERM.PAS --- General Terminal Emulator for PIBTERM      *)
  3. (*----------------------------------------------------------------------*)
  4. (*                                                                      *)
  5. (*  Author:  Philip R. Burns                                            *)
  6. (*  Version: 1.0   (November, 1986)  for v4.0 of PibTerm.               *)
  7. (*  Systems: For MS-DOS on IBM PCs and close compatibles only.          *)
  8. (*                                                                      *)
  9. (*  History: Original with me.                                          *)
  10. (*                                                                      *)
  11. (*----------------------------------------------------------------------*)
  12.  
  13. PROCEDURE Emulate_General_Terminal;
  14.  
  15. (*----------------------------------------------------------------------*)
  16. (*                                                                      *)
  17. (*     Procedure:  Emulate_General_Terminal                             *)
  18. (*                                                                      *)
  19. (*     Purpose:    Controls general terminal emulation                  *)
  20. (*                                                                      *)
  21. (*     Calling Sequence:                                                *)
  22. (*                                                                      *)
  23. (*        Emulate_General_Terminal;                                     *)
  24. (*                                                                      *)
  25. (*      Calls:   Async_Send                                             *)
  26. (*               Async_Receive                                          *)
  27. (*               KeyPressed                                             *)
  28. (*               Process_Command                                        *)
  29. (*               Display_Character                                      *)
  30. (*               Async_Buffer_Full                                      *)
  31. (*                                                                      *)
  32. (*----------------------------------------------------------------------*)
  33.  
  34. VAR
  35.    Done           : BOOLEAN    (* TRUE to exit terminal emulation mode *);
  36.    Ch             : CHAR       (* Character read/written               *);
  37.    B              : BOOLEAN    (* General boolean flag                 *);
  38.    ClrScr_Req     : BOOLEAN    (* Clear screen request                 *);
  39.    Save_Do_Status : BOOLEAN    (* Saves status line status             *);
  40.  
  41. BEGIN (* Emulate_General_Terminal *)
  42.  
  43.                                   (* Initialize text mode display   *)
  44.    Init_Text_Terminal;
  45.                                   (* Set other emulation variables  *)
  46.  
  47.    Reset_General_Terminal( FALSE );
  48.  
  49.                                    (* Not done here yet *)
  50.    Done := FALSE;
  51.                                    (* Loop over input until done *)
  52.    WHILE ( NOT Done ) DO
  53.       BEGIN
  54.                                    (* Check for character typed at keyboard *)
  55.          IF KeyPressed THEN
  56.             BEGIN
  57.  
  58.                Save_Do_Status := Do_Status_Line;
  59.  
  60.                Handle_Keyboard_Input( Done , Reset_Requested ,
  61.                                       ClrScr_Req );
  62.                IF Reset_Requested THEN
  63.                   BEGIN
  64.                      Clear_Window;
  65.                      Reset_General_Terminal( TRUE );
  66.                   END
  67.                ELSE IF ClrScr_Req THEN
  68.                   Clear_Window
  69.                ELSE IF ( Save_Do_Status <> Do_Status_Line ) THEN
  70.                   BEGIN
  71.  
  72.                      IF Do_Status_Line THEN
  73.                         Ansi_Last_Line := Max_Screen_Line - 1
  74.                      ELSE
  75.                         Ansi_Last_Line := Max_Screen_Line;
  76.  
  77.                      Window( 1, 1, Max_Screen_Col, Ansi_Last_Line );
  78.  
  79.                      Set_Screen_Size( Ansi_Last_Line , Max_Screen_Col );
  80.  
  81.                   END;
  82.  
  83.             END   (* KeyPressed *);
  84.  
  85.          IF ( Script_File_Mode AND ( NOT ( Done OR Really_Wait_String ) ) ) THEN
  86.             BEGIN
  87.                Get_Script_Command( PibTerm_Command );
  88.                Execute_Command   ( PibTerm_Command , Done , TRUE );
  89.             END;
  90.                                    (* Hold everything while scroll lock on *)
  91.  
  92.          IF Scroll_Lock_On THEN
  93.             Handle_Scroll_Lock;
  94.                                    (* Handle carrier drop *)
  95.          IF Carrier_Dropped THEN
  96.             Handle_Carrier_Drop;
  97.                                    (* Process character from remote *)
  98.  
  99.          IF ( Async_Buffer_Head <> Async_Buffer_Tail ) THEN
  100.             BEGIN
  101.                                    (* Get the character *)
  102.  
  103.                B := Async_Receive( Ch );
  104.  
  105.                                    (* Strip high bit if requested *)
  106.  
  107.                IF Auto_Strip_High_Bit THEN
  108.                   Ch := CHR( ORD( Ch ) AND $7F );
  109.  
  110.                                    (* Perform translation *)
  111.  
  112.                Ch := TrTab[Ch];
  113.  
  114.                                    (* Display the character received, but *)
  115.                                    (* check CompuServe B protocol request *)
  116.  
  117.                IF ( ORD( Ch ) = ENQ ) THEN
  118.                   BEGIN
  119.                      IF CompuServe_B_On THEN
  120.                         B := Do_CompuServe_B_Transfer
  121.                      ELSE
  122.                         IF Use_Dos_Con_Output THEN
  123.                            Display_Character_Through_DOS( Ch )
  124.                         ELSE
  125.                            B := Do_Display_Action( Ch , Done );
  126.                   END
  127.                ELSE
  128.                   BEGIN
  129.                      IF Use_Dos_Con_Output THEN
  130.                         Display_Character_Through_DOS( Ch )
  131.                      ELSE
  132.                         B := Do_Display_Action( Ch , Done );
  133.                   END;
  134.  
  135.                IF Do_Script_Tests THEN
  136.                   Do_Script_Checks( Ch );
  137.  
  138.             END
  139.                                    (* Check if waitstring time exhausted *)
  140.          ELSE
  141.             BEGIN
  142.                Async_Line_Status := Async_Line_Status AND $FD;
  143.                IF Really_Wait_String THEN
  144.                   Check_Wait_String_Time;
  145.                IF ( ( NOT KeyPressed ) AND ( NOT Script_File_Mode ) ) THEN
  146.                   IF ( Async_Buffer_Head = Async_Buffer_Tail ) THEN
  147.                      GiveAwayTime( 1 );
  148.             END;
  149.  
  150.       END;
  151.                                    (* Reset whole screen as window *)
  152.  
  153.    Window( 1, 1, Max_Screen_Col, Max_Screen_Line );
  154.  
  155. END   (* Emulate_General_Terminal *);
  156.